/*
 * Powered By fanrenqij.com
 * Since 2017 - 2017
 */

package com.fanrenqiji.modules.business.teacher.dao;

import com.fanrenqiji.common.persistence.BaseDao;
import com.fanrenqiji.common.persistence.BaseDaoImpl;
import com.fanrenqiji.entity.TeacherEntity;
import com.fanrenqiji.modules.sys.entity.Office;
import com.fanrenqiji.modules.sys.entity.User;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
/**
 * 持久化接口
 */
public interface TeacherDao extends TeacherDaoCustom, CrudRepository<TeacherEntity, Long> {

    @Query("from TeacherEntity where delFlag='" + TeacherEntity.DEL_FLAG_NORMAL + "' order by id desc")
    public List<TeacherEntity> findAllList();


    @Query("from TeacherEntity where delFlag='" + TeacherEntity.DEL_FLAG_NORMAL + "' and status =?1 order by id")
    public List<TeacherEntity> findTeacherEntityByStatus(int status);

    @Modifying
    @Query("update TeacherEntity set delFlag='" + TeacherEntity.DEL_FLAG_DELETE + "' where id = ?1 ")
    void deleteById(Long id);

    @Query("from TeacherEntity where companyId = ?1 and delFlag = '"
            + TeacherEntity.DEL_FLAG_NORMAL + "'")
    public List<TeacherEntity> findTeacherByOffice(Long office);

    @Query("from TeacherEntity where phone = ?1 and delFlag = " + TeacherEntity.DEL_FLAG_NORMAL + "")
    public List<TeacherEntity> findTeacherByPhone(String phone);
}


interface TeacherDaoCustom extends BaseDao<TeacherEntity> {
}

@Repository
class TeacherDaoImpl extends BaseDaoImpl<TeacherEntity> implements TeacherDaoCustom {

}
